home *** CD-ROM | disk | FTP | other *** search
/ The Fatted Calf / The Fatted Calf.iso / Unix / CNews / Source / inject / intcode.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-09-11  |  904 b   |  37 lines

  1. /*
  2.  * intcode - print an integer compactly but safely
  3.  *    (using RFC 822/1036 safe character set)
  4.  */
  5.  
  6.  
  7. #include <stdio.h>
  8. #include <sys/types.h>
  9.  
  10. /* private data */
  11. #ifdef notdef
  12. /*
  13.  * This alphabet is safe according to RFCs 822 and 1036 and excludes
  14.  * characters likely to be munged by Bitnet ( ^ ` { | } ~ ).
  15.  * Some B Newses fold case, so we can't use both cases.
  16.  */
  17. static char alphabet[] = "!#$%&'*+-=?_0123456789abcdefghijklmnopqrstuvwxyz";
  18. #endif
  19. /*
  20.  * However, we are using this smaller alphabet in the interests of
  21.  * extreme caution, since a message-id is pretty fundamental to netnews
  22.  * and only the alphanumerics seem really safe from munging.
  23.  */
  24. static char alphabet[] = "0123456789ABCDEFGHIJKLMnopqrstuvwxyz";
  25.  
  26. #define RADIX (sizeof alphabet - 1)
  27.  
  28. intcode(tm)
  29. time_t tm;
  30. {
  31.     register time_t nextl = tm / RADIX;
  32.  
  33.     if (nextl > 0)
  34.         intcode(nextl);
  35.     (void) putchar(alphabet[tm % RADIX]);
  36. }
  37.